using System;
using System.Collections.Generic;
using iPhOwa.Exchange.ContentClasses;
using iPhOwa.Exchange.ContentClasses.Fields;
using iPhOwa.Exchange.WebDav.Methods;

namespace iPhOwa.Exchange.Managers
{
	/// <summary>
	/// Encapsulates working with person.
	/// </summary>
	public static class ContactManager
	{
		/// <summary>
		/// Get a list of persons.
		/// </summary>
		public static ICollection<Contact> GetList(Uri path, OwaSession session)
		{
			string[] properties = new string[]
					{
							ContactFields.FirstName
							, ContactFields.LastName
							, ContactFields.Organization
							, ContactFields.Mobile
							, ContactFields.TelephoneNumber
					};

			Search search = new Search(path, session, properties);

			List<Item> items = new List<Item>(search.Run());

			return items.ConvertAll<Contact>(delegate(Item i)
			                                	{
			                                		return i as Contact;
			                                	});
		}
	}
}